package com.SouthernWall_404.age_tool.common.world.block.TriggerBlocks;

import com.SouthernWall_404.age_tool.common.init.ModBlocks;
import com.SouthernWall_404.age_tool.common.world.item.ExcuteBlockItem;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;

public class LeftClickTriggerBlock extends AbstractTriggerBlock{

    public LeftClickTriggerBlock(Properties p_54120_) {
        super(p_54120_.strength(2.0f)
                .noOcclusion()
                .dynamicShape());


    }

    

    @Override
    public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand hand, BlockHitResult blockPlaceContext) {
        ItemStack itemStack=player.getItemInHand(hand);
        if(!(itemStack.getItem()instanceof ExcuteBlockItem))
        {
            this.triggered(level,blockPos);
        }
        return super.use(blockState, level, blockPos, player, hand, blockPlaceContext);
    }

    @Override
    public @Nullable <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
        if(this.defaultBlock.is(Blocks.AIR))
        {
//            this.defaultBlock= ModBlocks.LEFT_CLICK_TRIGGER_DISPLAY_BLOCK.get().defaultBlockState();
        }
        return super.getTicker(level, blockState, blockEntityType);
    }
}
